home *** CD-ROM | disk | FTP | other *** search
/ Info-Mac 4 / Info_Mac IV CD-ROM (Pacific HiTech Inc.)(August 1994).iso / Development / General / ViewIt™ 2.24 Shareware / FORTRAN Demo Projects / Absoft MacFortran II 3.2 Demos / vDemoAF.f < prev    next >
Text File  |  1993-09-21  |  5KB  |  146 lines

  1. C NOTE: Read the "MPW Fortrans" section of "About Compilers"
  2. C before compiling AF programs that use FaceWare modules.
  3.  
  4. C ViewIt 2.2 Demonstration Program
  5. C ©FaceWare 1991-93. All Rights Reserved.
  6.  
  7.     GLOBAL DEFINE
  8.     include "Types.inc"
  9.     include "QuickDraw.inc"
  10.     include "Controls.inc"
  11.     include "Events.inc"
  12.     include "OSUtils.inc"
  13.     include "OSEvents.inc"
  14.     include "SegLoad.inc"
  15.     include "Files.inc"
  16.     include "Resources.inc"
  17.     include "FaceStorAF.inc"
  18.     END
  19.  
  20.     include "FaceProcAF.inc"
  21.  
  22.       PROGRAM vDemoAF
  23.     implicit none
  24.       record /FaceRec/ fRec
  25.       common/FaceStuff/fRec
  26.     structure /DataRec/
  27.       integer*2 myInteger
  28.       real*4 myReal
  29.       character*100 myString
  30.       integer*4 myFlags
  31.     end structure
  32.     record/DataRec/myRec
  33.     real*4 theReal,delta
  34.     logical*4 helpShown
  35.     integer*2 myList
  36.     integer*4 myPtr,oldTicks,newTicks
  37.     integer*4 OverProc
  38.     pascal external OverProc
  39.  
  40.     myRec.myInteger = 0
  41.     myRec.myReal = 6.2
  42.     myRec.myString = 'Hello'
  43.     myRec.myFlags = 10
  44.     myList = 2
  45.     oldTicks = 0
  46.     theReal = 6.0
  47.  
  48. C Initialize FaceIt
  49.       fRec.uName = 'vDemo.Rsrc'
  50.       call FaceIt(0,DoInit,0,0,0,0)
  51.  
  52. C Open Modeless Window using FWND 1000
  53.     call FaceIt(0,NewWnd,1000,1,0,0)
  54.  
  55.       do while (.true.)
  56.         call FaceIt(0,DoLoop,0,0,0,0)
  57. C Standard "About" Menu Item Selection
  58.       if ((fRec.uMenuID == 101).and.(fRec.uMenuItem == 1)) then
  59.         fRec.uString = 'Demonstration of the use of ViewIt'
  60.      +//char(13)//'windows in a FaceIt-based program.'
  61.         call FaceIt(0,ShoStr,3,12,(1 + (409*65536)),0)
  62. C Hit in Modeless Window's "Open Modal" Button
  63.       else if ((fRec.uMenuID == 1000).and.(fRec.wcHit == 2)) then
  64.         call FaceIt(0,NewWnd,1001,0,0,0)  !Open Modal Window
  65.         do while (.true.)
  66.           call FaceIt(0,MdlWnd,1001,0,0,0)  !Process Modal Events
  67.         if (fRec.wcHit == -1) then        !Hit in Close Box
  68.           exit
  69.         else if (fRec.wcHit == 1) then    !Hit in "Open Nested"
  70.           myPtr = %loc(myRec)
  71.           call FaceIt(0,NewWnd,1002,0,110,myPtr)!Open Nested Modal
  72.           call FaceIt(0,GetCtl,1002,0,3,3)    !Link Scrollable List
  73.           call FaceIt(0,LnkCtl,fRec.cControl,%loc(myList),2,0)
  74.           call FaceIt(0,GetCtl,1002,0,2,3)      !Set Override Proc
  75.           call FaceIt(0,OvrCtl,fRec.cControl,OverProc,0,0)
  76.           call FaceIt(0,SetVal,1002,0,0,0)      !Set Linked Values
  77.           helpShown = .false.
  78.           do while (.true.)
  79.             call FaceIt(0,MdlWnd,1002,-2,0,0) !Process Modal Events
  80.             if (fRec.uMenuID == 0) then       !No Message
  81.               newTicks = TickCount()
  82.             if (newTicks > oldTicks + 60) then
  83.               oldTicks = newTicks
  84.               call FaceIt(0,GetCtl,1002,0,2,8)
  85.               call SetCtlValue(%val4(fRec.cControl),
  86.      +            %val2(mod(fRec.cValue,4) + 1))
  87.             end if
  88.             else if (fRec.wvHit == 1) then      !Hit in View #1
  89.               if (fRec.wcHit == 1) then      !Hit in "OK" Button
  90.               exit
  91.             else if (fRec.wcHit == 2) then  !Hit in "Show/Hide"
  92.               if (helpShown) then
  93.                 call FaceIt(0,ShoCtl,0,0,-3,2)  !Hide v3, Show v2
  94.                 helpShown = .false.
  95.               else
  96.                 call FaceIt(0,ShoCtl,0,0,-2,3)  !Hide v2, Show v3
  97.                 helpShown = .true.
  98.               end if
  99.             end if
  100.             else if (fRec.wvHit == 2) then    !Hit in View #2
  101.               if ((fRec.wcHit == 6).or.(fRec.wcHit == 7)) then
  102.               call FaceIt(0,GetCtl,1002,0,2,int(fRec.wcHit))
  103.               delta = 0.001 * (fRec.cMin - 2)
  104.               myRec.myReal = myRec.myReal + delta
  105.               call FaceIt(0,SetVal,0,0,2,2)
  106.               call Delay(%val4(5),fRec.uI4)
  107.             end if
  108.             end if
  109.           end do
  110.           call FaceIt(0,GetVal,1002,0,0,0)      !Get Linked Values
  111.           call FaceIt(0,EndWnd,1002,0,0,0)      !Close Nested Modal
  112.         end if
  113.         end do
  114.         call FaceIt(0,EndWnd,1001,0,0,0)  !Close Modal Window
  115. C Hit in Modeless Window's "Why ViewIt?" Button
  116.       else if ((fRec.uMenuID == 1000).and.(fRec.wcHit == 3)) then
  117.         call FaceIt(0,NewWnd,1003,0,0,%loc(theReal))
  118.         call FaceIt(0,SetVal,1003,0,0,0)
  119.         do while (.true.)
  120.           call FaceIt(0,MdlWnd,1003,0,0,0)
  121.         if (fRec.wcHit == 1) exit
  122.         end do
  123.         call FaceIt(0,GetVal,1003,0,0,0)
  124.         call FaceIt(0,EndWnd,1003,0,0,0)
  125.       end if
  126.       end do
  127.       end
  128.  
  129. C NOTE: Use of a procedure like "OverProc" that is called by ViewIt
  130. C requires that it be compiled with the "-k" option set.  See your
  131. C MacFortran II manual for more info about the "-k" compiler option.
  132.     PASCAL SUBROUTINE OverProc(thePtr)
  133.     value thePtr
  134.     implicit none
  135.     integer*4 JumpIt,thePtr
  136.     inline (JumpIt = /z'2257',z'2051',z'4e90'/)
  137.       record /FaceRec/ fRec
  138.       common/FaceStuff/fRec
  139.     if (fRec.uCommand == 264) then    !a key down message?
  140.       if (fRec.uParam(1) == 32) then    !SPACE key pressed?
  141.         fRec.uParam(1) = 95            !convert to UNDERLINE
  142.       end if
  143.     end if
  144.     call JumpIt(%val4(thePtr))        !pass message to driver
  145.     end
  146.